import MySQLdb
import datetime
f=open('c:/mysql2/repl_monitor.txt','a')
conn=MySQLdb.connect(host="10.0.2.4",user="mars",passwd="123456",db="mysql",port=3307,charset="utf8")
cursor=conn.cursor()
sqlstr="show slave status"
cursor.execute(sqlstr)
results=cursor.fetchall()
if results[0][10] == "Yes" and results[0][11] == "Yes":
    print "repl is ok!!"
    f.write("repl is ok!!  " + str(datetime.datetime.now())+'\n')
else:
    print "repl is bad!!"
    f.write("repl is bad!!  " + str(datetime.datetime.now())+'\n')

f.close()

